<template>
  <view class="container screen-width">
    <view class="tab_title">
      <image src="../../static/returnimg.png" mode @tap="backPage" />
      <text>公示名单</text>
    </view>
    <view class="content">
      <view class="policy-list" v-if="publicList.length">
        <view class="title-lable flex space-between">
          <view class="num">序号</view>
          <view class="name">企业名称</view>
        </view>
        <view
          class="policy-item flex space-between"
          v-for="(item,index) in publicList"
          :key="index"
        >
          <view class="lable">{{index + 1}}</view>
          <view @click="toCompany(item)" class="name">{{ item.companyName }}</view>
        </view>
        <van-divider
          v-show="publicList.length && total < total + 1"
          content-position="center"
        >我也是有底线的</van-divider>
      </view>
      <van-divider v-else content-position="center">我也是有底线的</van-divider>
    </view>
    <Festival></Festival>
  </view>
</template>
<script>
import { getCompanyListOfNames } from "../../util/api/policy.js";
export default {
  data() {
    return {
      search: {
        batchNumber: "",
        projectName: "",
        pageNo: 1,
        pageSize: 15
      },
      publicList: [],
      total: 0
    };
  },
  onLoad(e) {
    this.search.batchNumber = e.num;
    this.search.projectName = e.name;

    this.getPublicList();
  },
  onReachBottom() {
    if (this.publicList.length >= this.total) return;
    this.search.pageNo += 1;
    this.getPublicList();
  },
  methods: {
    backPage() {
      uni.navigateBack({
        // 点击返回到上一页
        delta: 1
      });
    },
    getPublicList() {
      getCompanyListOfNames(this.search).then(res => {
        this.publicList = this.publicList.concat(res.result.records);
        this.total = res.result.total;
      });
    },
    toCompany(item) {
      uni.navigateTo({
        url: `/pages/enterpriseDetails/brand_detail?id=${item.companyId}&type=1&liIndex=0&showNew=true`
      });
    }
  }
};
</script>
<style lang="less" scoped>
.container {
  width: 100%;
  .tab_title {
    padding-left: 30rpx;
    height: 90rpx;
    display: flex;
    align-items: center;
    background-color: #2862ad;
    image {
      width: 18rpx;
      height: 34rpx;
      margin-left: 10rpx;
    }
    text {
      color: #fff;
      font-size: 34rpx;
      margin-left: 40rpx;
    }
  }
  .content {
    padding: 20upx 30upx;
    box-sizing: border-box;
    width: 100%;
    .policy-list {
      width: 100%;
      .title-lable {
        width: 100%;
        padding: 30upx;
        box-sizing: border-box;
        font-size: 30upx;
        font-weight: bold;
        border-bottom: 1px solid #eee;
        .num {
          width: 15%;
        }
        .name {
          width: 82%;
        }
      }
      .policy-item {
        background: #fff;
        padding: 30upx;
        box-sizing: border-box;
        // margin-bottom: 20upx;
        border-bottom: 1px solid #eee;
        .lable {
          // margin-bottom: 10upx;
          // font-weight: 600;
          width: 15%;
        }
        .name {
          font-size: 28upx;
          color: #1678ff;
          width: 82%;
        }
      }
      .policy-item:nth-child(odd) {
        background: #f5f5f5;
      }
    }
  }
}
</style>